package com.wjm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.wjm.entity.Desk;
import com.wjm.mapper.interf.DeskMapper;
import com.wjm.service.interf.DeskServiceInterface;

@Service("deskService")
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) 
public class DeskServiceImpl implements DeskServiceInterface {

	@Autowired
	private DeskMapper deskMapper;
	
	@Override
	public boolean save(Desk object) throws Exception {
		boolean result = false;
		if(deskMapper.save(object) > 0){
			result = true;
		}
		return result;
	}

	@Override
	public boolean delete(int objectId) throws Exception {
		boolean result = false;
		if(deskMapper.delete(objectId) > 0){
			result = true;
		}
		return result;
	}

	@Override
	public boolean update(Desk object) throws Exception {
		boolean result = false;
		if(deskMapper.update(object) > 0){
			result = true;
		}
		return result;
	}

	@Override
	public int saveBatch(List<Desk> list) throws Exception {
		return deskMapper.saveBatch(list);
	}

	@Override
	public List<Desk> queryByPage(int current, int number, int crId, int deskNo) throws Exception {
		current = number * (current - 1);
		return deskMapper.selectByPage(current, number, crId, deskNo);
	}

	@Override
	public List<Desk> queryByCr(int crId) throws Exception {
		return deskMapper.selectByCr(crId);
	}

	@Override
	public int deleteByCr(int crId) throws Exception {
		return deskMapper.deleteByCr(crId);
	}
}
